#ifndef CLOCKSTATTREEMODEL_H
#define CLOCKSTATTREEMODEL_H

// Qt lib import
#include <QObject>
#include <QAbstractItemModel>
#include <QDebug>
#include <QString>
#include <QNetworkReply>
#include "treeitem.h"

class ClockStatTreeModel: public QAbstractItemModel
{
    Q_OBJECT
    Q_ENUMS(InfoRoles)
private:
    TreeItem *m_rootItem;//顶级item
    QNetworkAccessManager *_nam;
public:
    enum InfoRoles {
        TitleRole = Qt::UserRole+1,//标题
        DayRole,//天数
        DateRole,//日期
        WeekRole,//星期
    };

    explicit ClockStatTreeModel(QObject *parent = 0);

    ~ClockStatTreeModel();

    QVariant data(const QModelIndex &index, int role) const;

    Qt::ItemFlags flags(const QModelIndex &index) const;

    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;

    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;

    QModelIndex parent(const QModelIndex &index) const;

    int rowCount(const QModelIndex &parent = QModelIndex()) const;

    int columnCount(const QModelIndex &parent = QModelIndex()) const;

    QHash<int,QByteArray> roleNames() const;

public slots:
    QAbstractItemModel *model();
    bool hasParent(const QModelIndex &index) const;

	//登录请求
    void slot_stat_req(QString user_id);
	//登录响应
	void slot_stat_res(QNetworkReply *reply);

signals:
	void sig_stat_result(int code, QString msg);

};

#endif // CLOCKSTATTREEMODEL_H
